package router

import (
	"github.com/gin-gonic/gin"
	_ "github.com/gin-gonic/gin"
	azx "go-admin/apis/zx"
	jwt "go-admin/pkg/jwtauth"
)

// 路由示例
func InitZxRouter(r *gin.Engine, authMiddleware *jwt.GinJWTMiddleware) *gin.Engine {

	// 无需认证的路由
	// 需要认证的路由
	v1 := r.Group("/api/v1")
	registerZxOrderRouter(v1, authMiddleware)
	registerZxSignRouter(v1, authMiddleware)
	registerZxDesignRouter(v1, authMiddleware)
	registerZxBuildRouter(v1, authMiddleware)
	registerZxRevisitRouter(v1, authMiddleware)
	//registerZxlibRouter(v1, authMiddleware)

	//registerZxOrderRouterOut(v1)
	//registerZxSignRouterOut(v1)
	//registerZxDesignRouterOut(v1)
	//registerZxBuildRouterOut(v1)
	//registerZxRevisitRouterOut(v1)
	registerZxlibRouterOut(v1)

	return r
}

// 需认证的路由代码
func registerZxOrderRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) {

	r := v1.Group("/zxorder").Use(authMiddleware.MiddlewareFunc())
	//.Use(middleware.AuthCheckRole())
	{
		r.GET("/:id", azx.GetZxOrder)
		r.POST("", azx.InsertZxOrder)
		r.PUT("", azx.UpdateZxOrder)
		r.DELETE("/:id", azx.DeleteZxOrder)
	}

	l := v1.Use(authMiddleware.MiddlewareFunc())
	//.Use(middleware.AuthCheckRole())
	{
		l.GET("/zxorderList", azx.GetZxOrderList)
	}

}

// 无需认证的路由代码
func registerZxOrderRouterOut(v1 *gin.RouterGroup) {

	v1.GET("/zxorderList", azx.GetZxOrderList)

	r := v1.Group("/zxorder")
	{
		r.GET("/:id", azx.GetZxOrder)
		r.POST("", azx.InsertZxOrder)
		r.PUT("", azx.UpdateZxOrder)
		r.DELETE("/:id", azx.DeleteZxOrder)
	}
}

// 需认证的路由代码
func registerZxBuildRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) {

	r := v1.Group("/zxbuild").Use(authMiddleware.MiddlewareFunc())
	//.Use(middleware.AuthCheckRole())
	{
		r.GET("/one/:id", azx.GetZxBuild)
		r.POST("", azx.InsertZxBuild)
		r.PUT("", azx.UpdateZxBuild)
		r.DELETE("/:id", azx.DeleteZxBuild)
	}

	l := v1.Group("").Use(authMiddleware.MiddlewareFunc())
	//.Use(middleware.AuthCheckRole())
	{
		l.GET("/zxbuildList", azx.GetZxBuildList)
	}

}

// 无需认证的路由代码
func registerZxBuildRouterOut(v1 *gin.RouterGroup) {

	v1.GET("/zxbuildList", azx.GetZxBuildList)

	r := v1.Group("/zxbuild")
	{
		r.GET("/one/:id", azx.GetZxBuild)
		r.POST("", azx.InsertZxBuild)
		r.PUT("", azx.UpdateZxBuild)
		r.DELETE("/:id", azx.DeleteZxBuild)
	}
}

// 需认证的路由代码
func registerZxDesignRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) {

	r := v1.Group("/zxdesign").Use(authMiddleware.MiddlewareFunc())
	//.Use(middleware.AuthCheckRole())
	{
		r.GET("/one/:id", azx.GetZxDesign)
		r.POST("", azx.InsertZxDesign)
		r.PUT("", azx.UpdateZxDesign)
		r.DELETE("/:id", azx.DeleteZxDesign)
	}

	l := v1.Group("").Use(authMiddleware.MiddlewareFunc())
	//.Use(middleware.AuthCheckRole())
	{
		l.GET("/zxdesignList", azx.GetZxDesignList)
	}

}

// 无需认证的路由代码
func registerZxDesignRouterOut(v1 *gin.RouterGroup) {

	v1.GET("/zxdesignList", azx.GetZxDesignList)

	r := v1.Group("/zxdesign")
	{
		r.GET("/one/:id", azx.GetZxDesign)
		r.POST("", azx.InsertZxDesign)
		r.PUT("", azx.UpdateZxDesign)
		r.DELETE("/:id", azx.DeleteZxDesign)
	}
}

// 需认证的路由代码
func registerZxlibRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) {

	r := v1.Group("/zxlib").Use(authMiddleware.MiddlewareFunc())
	//.Use(middleware.AuthCheckRole())
	{
		r.GET("/images/:module/:id", azx.GetZxlibImages)
		r.POST("/uploads/:module/:id", azx.UploadsZxlibImages)
		r.POST("/removeImages", azx.DeleteZxlibImages)
		//r.POST("/removeImages/:module/:id/:name", azx.DeleteZxlibImages)
	}
}

// 无需认证的路由代码
func registerZxlibRouterOut(v1 *gin.RouterGroup) {

	r := v1.Group("/zxlib")
	{
		r.GET("/images/:module/:id", azx.GetZxlibImages)
		r.POST("/uploads/:module/:id", azx.UploadsZxlibImages)
		r.POST("/removeImages", azx.DeleteZxlibImages)
		r.POST("/removeImages/:module/:id/:name", azx.DeleteZxlibImages)
	}
}

// 需认证的路由代码
func registerZxSignRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) {

	r := v1.Group("/zxsign").Use(authMiddleware.MiddlewareFunc())
	//.Use(middleware.AuthCheckRole())
	{
		r.GET("/:id", azx.GetZxSign)
		r.POST("", azx.InsertZxSign)
		r.PUT("", azx.UpdateZxSign)
		r.DELETE("/:id", azx.DeleteZxSign)
	}

	l := v1.Group("").Use(authMiddleware.MiddlewareFunc())
	//.Use(middleware.AuthCheckRole())
	{
		l.GET("/zxsignList", azx.GetZxSignList)
	}

}

// 无需认证的路由代码
func registerZxSignRouterOut(v1 *gin.RouterGroup) {

	v1.GET("/zxsignList", azx.GetZxSignList)

	r := v1.Group("/zxsign")
	{
		r.GET("/:id", azx.GetZxSign)
		r.POST("", azx.InsertZxSign)
		r.PUT("", azx.UpdateZxSign)
		r.DELETE("/:id", azx.DeleteZxSign)
	}
}

// 需认证的路由代码
func registerZxRevisitRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) {

	r := v1.Group("/zxrevisit").Use(authMiddleware.MiddlewareFunc())
	//.Use(middleware.AuthCheckRole())
	{
		r.GET("/:id", azx.GetZxRevisit)
		r.POST("", azx.InsertZxRevisit)
		r.PUT("", azx.UpdateZxRevisit)
		r.DELETE("/:id", azx.DeleteZxRevisit)
	}

	l := v1.Use(authMiddleware.MiddlewareFunc())
	//.Use(middleware.AuthCheckRole())
	{
		l.GET("/zxrevisitList", azx.GetZxRevisitList)
	}

}

// 无需认证的路由代码
func registerZxRevisitRouterOut(v1 *gin.RouterGroup) {

	v1.GET("/zxrevisitList", azx.GetZxRevisitList)

	r := v1.Group("/zxrevisit")
	{
		r.GET("/:id", azx.GetZxRevisit)
		r.POST("", azx.InsertZxRevisit)
		r.PUT("", azx.UpdateZxRevisit)
		r.DELETE("/:id", azx.DeleteZxRevisit)
	}
}
